#include "adminmenuwidget.h"
#include <QApplication>
#include <QMenu>
#include <QDateTime>
#include <QRegularExpression>
#include <QScrollArea>
#include <QFormLayout>

AdminMenuWidget::AdminMenuWidget(QWidget *parent)
    : QWidget(parent)
    , m_menuManager(nullptr)
    , m_mainLayout(nullptr)
    , m_searchLabel(nullptr)
    , m_searchEdit(nullptr)
    , m_categoryLabel(nullptr)
    , m_categoryFilter(nullptr)
    , m_refreshButton(nullptr)
    , m_manageCategoriesButton(nullptr)
    , m_menuTable(nullptr)
    , m_buttonLayout(nullptr)
    , m_buttonWidget(nullptr)
    , m_addButton(nullptr)
    , m_editButton(nullptr)
    , m_deleteButton(nullptr)
    , m_statusLabel(nullptr)
    , m_progressBar(nullptr)
    , m_searchTimer(nullptr)
{
    setupUI();
    setupConnections();
    applyStyles();
    
    // 初始化搜索定时器
    m_searchTimer = new QTimer(this);
    m_searchTimer->setSingleShot(true);
    m_searchTimer->setInterval(300); // 300ms防抖
    connect(m_searchTimer, &QTimer::timeout, this, &AdminMenuWidget::filterMenuData);
}

AdminMenuWidget::~AdminMenuWidget()
{
    // Qt会自动清理子对象
}

void AdminMenuWidget::setMenuManager(MenuManager *manager)
{
    if (m_menuManager) {
        // 断开原有连接
        disconnect(m_menuManager, nullptr, this, nullptr);
    }
    
    m_menuManager = manager;
    
    if (m_menuManager) {
        // 连接信号
        connect(m_menuManager, &MenuManager::menuItemAdded,
                this, &AdminMenuWidget::onMenuItemAdded);
        connect(m_menuManager, &MenuManager::menuItemUpdated,
                this, &AdminMenuWidget::onMenuItemUpdated);
        connect(m_menuManager, &MenuManager::menuItemDeleted,
                this, &AdminMenuWidget::onMenuItemDeleted);
        connect(m_menuManager, &MenuManager::stockUpdated,
                this, &AdminMenuWidget::onStockUpdated);
        connect(m_menuManager, &MenuManager::categoriesChanged,
                this, &AdminMenuWidget::onCategoriesChanged);
        connect(m_menuManager, &MenuManager::salesCountUpdated,
                this, &AdminMenuWidget::onSalesCountUpdated);
        
        // 延迟连接DataManager的外部文件变更信号，避免初始化冲突
        QTimer::singleShot(100, this, [this]() {
            connect(&DataManager::instance(), &DataManager::externalFileChanged,
                    this, &AdminMenuWidget::onExternalFileChanged);
        });
        
        // 延迟加载数据，避免在信号连接过程中引起死锁
        QTimer::singleShot(0, this, &AdminMenuWidget::refreshData);
    }
}

void AdminMenuWidget::refreshData()
{
    if (!m_menuManager) {
        showStatusMessage("菜单管理器未初始化", true);
        return;
    }
    
    loadMenuData();
    updateCategoryFilter();
    filterMenuData();
    showStatusMessage("数据已刷新");
}

void AdminMenuWidget::setupUI()
{
    // 主布局 - 使用垂直布局
    m_mainLayout = new QVBoxLayout(this);
    m_mainLayout->setContentsMargins(5, 5, 5, 5);
    m_mainLayout->setSpacing(5);
    
    // 搜索和过滤区域
    QHBoxLayout *filterLayout = new QHBoxLayout();
    filterLayout->setSpacing(5);
    
    m_searchLabel = new QLabel("搜索:", this);
    m_searchLabel->setMinimumWidth(35);
    m_searchEdit = new QLineEdit(this);
    m_searchEdit->setPlaceholderText("菜品名称或ID...");
    m_searchEdit->setMaximumWidth(200);
    
    m_categoryLabel = new QLabel("分类:", this);
    m_categoryLabel->setMinimumWidth(35);
    m_categoryFilter = new QComboBox(this);
    m_categoryFilter->addItem("全部分类");
    m_categoryFilter->setMaximumWidth(150);
    
    m_refreshButton = new QPushButton("刷新", this);
    m_refreshButton->setMaximumWidth(80);
    m_manageCategoriesButton = new QPushButton("管理分类", this);
    m_manageCategoriesButton->setMaximumWidth(100);
    
    filterLayout->addWidget(m_searchLabel);
    filterLayout->addWidget(m_searchEdit);
    filterLayout->addWidget(m_categoryLabel);
    filterLayout->addWidget(m_categoryFilter);
    filterLayout->addWidget(m_refreshButton);
    filterLayout->addWidget(m_manageCategoriesButton);
    filterLayout->addStretch(); // 添加弹性空间
    
    m_mainLayout->addLayout(filterLayout);
    
    // 创建菜品表格
    setupMenuTable();
    m_mainLayout->addWidget(m_menuTable);
    
    // 操作按钮区域
    m_buttonWidget = new QWidget();
    m_buttonLayout = new QHBoxLayout(m_buttonWidget);
    m_buttonLayout->setContentsMargins(0, 0, 0, 0);
    
    m_addButton = new QPushButton("添加菜品", this);
    m_editButton = new QPushButton("编辑菜品", this);
    m_deleteButton = new QPushButton("删除菜品", this);
    
    m_buttonLayout->addWidget(m_addButton);
    m_buttonLayout->addWidget(m_editButton);
    m_buttonLayout->addWidget(m_deleteButton);
    m_buttonLayout->addStretch(); // 将按钮推到左侧
    
    m_mainLayout->addWidget(m_buttonWidget);
    
    // 状态显示
    m_statusLabel = new QPushButton("就绪", this);
    m_statusLabel->setObjectName("statusLabel");
    m_statusLabel->setEnabled(false);
    m_statusLabel->setFixedHeight(30);
    m_statusLabel->setStyleSheet(
        "QPushButton { "
        "background-color: #f8f9fa; "
        "color: #2c3e50; "
        "border: 2px solid #e9ecef; "
        "border-radius: 4px; "
        "padding: 6px 12px; "
        "font-size: 12px; "
        "font-weight: 500; "
        "text-align: center; "
        "}"
        "QPushButton:disabled { "
        "background-color: #f8f9fa; "
        "color: #2c3e50; "
        "border: 2px solid #e9ecef; "
        "}"
    );
    
    m_progressBar = new QProgressBar(this);
    m_progressBar->setVisible(false);
    
    m_mainLayout->addWidget(m_statusLabel);
    m_mainLayout->addWidget(m_progressBar);
    
    // 初始状态
    enableOperationButtons(false);
}

void AdminMenuWidget::setupMenuTable()
{
    m_menuTable = new QTableWidget(this);
    m_menuTable->setColumnCount(COL_COUNT);
    
    // 设置表头 - 移除创建时间列
    QStringList headers = {"ID", "菜品名称", "分类", "价格(元)", "库存", "销量"};
    m_menuTable->setHorizontalHeaderLabels(headers);
    
    // 表格设置 - 针对1024*600优化
    m_menuTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    m_menuTable->setSelectionMode(QAbstractItemView::SingleSelection);
    m_menuTable->setAlternatingRowColors(true);
    m_menuTable->setSortingEnabled(true);
    m_menuTable->setContextMenuPolicy(Qt::CustomContextMenu);
    
    // 设置表格为只读模式 - 菜品信息只能在右侧编辑区域修改
    m_menuTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
    
    // 优化表格行高和字体
    m_menuTable->verticalHeader()->setDefaultSectionSize(28); // 减小行高
    m_menuTable->verticalHeader()->hide(); // 隐藏行号
    QFont tableFont = m_menuTable->font();
    tableFont.setPointSize(9); // 减小字体
    m_menuTable->setFont(tableFont);
    
    // 列宽设置 - 针对小屏幕优化，移除创建时间列
    QHeaderView *header = m_menuTable->horizontalHeader();
    header->setSectionResizeMode(COL_ID, QHeaderView::Fixed);
    header->setSectionResizeMode(COL_NAME, QHeaderView::Stretch);
    header->setSectionResizeMode(COL_CATEGORY, QHeaderView::Fixed);
    header->setSectionResizeMode(COL_PRICE, QHeaderView::Fixed);
    header->setSectionResizeMode(COL_STOCK, QHeaderView::Fixed);
    header->setSectionResizeMode(COL_SALES, QHeaderView::Fixed);
    
    // 设置固定列宽
    m_menuTable->setColumnWidth(COL_CATEGORY, 80);
    m_menuTable->setColumnWidth(COL_PRICE, 70);
    m_menuTable->setColumnWidth(COL_STOCK, 50);
    m_menuTable->setColumnWidth(COL_SALES, 50);
    
    // 隐藏ID列
    m_menuTable->setColumnHidden(COL_ID, true);
}



void AdminMenuWidget::setupConnections()
{
    // 搜索和过滤
    connect(m_searchEdit, &QLineEdit::textChanged, this, [this]() {
        m_searchTimer->stop();
        m_searchTimer->start();
    });
    connect(m_categoryFilter, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &AdminMenuWidget::onCategoryFilterChanged);
    connect(m_refreshButton, &QPushButton::clicked,
            this, &AdminMenuWidget::onRefreshClicked);
    connect(m_manageCategoriesButton, &QPushButton::clicked,
            this, &AdminMenuWidget::onManageCategoriesClicked);
    
    // 表格操作
    connect(m_menuTable, &QTableWidget::itemSelectionChanged,
            this, &AdminMenuWidget::onMenuItemSelectionChanged);
    connect(m_menuTable, &QTableWidget::cellDoubleClicked,
            this, &AdminMenuWidget::onTableItemDoubleClicked);
    connect(m_menuTable, &QTableWidget::customContextMenuRequested,
            this, &AdminMenuWidget::onTableContextMenuRequested);
    
    // 操作按钮
    connect(m_addButton, &QPushButton::clicked,
            this, &AdminMenuWidget::onAddMenuItemClicked);
    connect(m_editButton, &QPushButton::clicked,
            this, &AdminMenuWidget::onEditMenuItemClicked);
    connect(m_deleteButton, &QPushButton::clicked,
            this, &AdminMenuWidget::onDeleteMenuItemClicked);
}

void AdminMenuWidget::applyStyles()
{
    setStyleSheet(R"(
        AdminMenuWidget {
            background-color: #f8f9fa;
            font-size: 12px; /* 减小整体字体 */
        }
        
        QTableWidget {
            gridline-color: #e0e0e0;
            background-color: white;
            selection-background-color: #3498db;
            selection-color: white;
            border: 1px solid #bdc3c7;
            border-radius: 3px; /* 减小圆角 */
            font-size: 11px;
        }
        
        QTableWidget::item {
            padding: 4px 6px; /* 减少内边距 */
            border-bottom: 1px solid #ecf0f1;
            height: 24px; /* 设置行高 */
        }
        
        QTableWidget::item:selected {
            background-color: #3498db;
            color: white;
        }
        
        QTableWidget QHeaderView::section {
            background-color: #34495e;
            color: white;
            padding: 5px; /* 减少内边距 */
            border: none;
            font-weight: bold;
            font-size: 11px;
            height: 26px; /* 减少表头高度 */
        }
        
        #editTitle {
            font-size: 14px; /* 减小字体 */
            font-weight: bold;
            color: #2c3e50;
            padding: 6px; /* 减少内边距 */
            background-color: #ecf0f1;
            border-radius: 3px;
        }
        
        QLineEdit, QComboBox, QSpinBox, QDoubleSpinBox {
            border: 1px solid #bdc3c7;
            border-radius: 3px;
            padding: 3px 6px; /* 减少内边距 */
            background-color: white;
            font-size: 11px;
            min-height: 20px; /* 减少最小高度 */
        }
        
        QLineEdit:focus, QComboBox:focus, QSpinBox:focus, QDoubleSpinBox:focus {
            border-color: #3498db;
        }
        
        QTextEdit {
            border: 1px solid #bdc3c7;
            border-radius: 3px;
            padding: 4px;
            background-color: white;
            font-size: 11px;
        }
        
        QTextEdit:focus {
            border-color: #3498db;
        }
        
        QPushButton {
            background-color: #3498db;
            color: white;
            border: none;
            padding: 6px 12px; /* 减少按钮内边距 */
            border-radius: 3px;
            font-weight: bold;
            font-size: 11px;
            min-height: 24px; /* 减少按钮高度 */
        }
        
        QPushButton:hover {
            background-color: #2980b9;
        }
        
        QPushButton:pressed {
            background-color: #21618c;
        }
        
        QPushButton:disabled {
            background-color: #bdc3c7;
            color: #7f8c8d;
        }
        
        QPushButton[objectName="deleteButton"] {
            background-color: #e74c3c;
        }
        
        QPushButton[objectName="deleteButton"]:hover {
            background-color: #c0392b;
        }
        
        QPushButton[objectName="saveButton"] {
            background-color: #27ae60;
        }
        
        QPushButton[objectName="saveButton"]:hover {
            background-color: #229954;
        }
        
        #statusLabel {
            color: #2c3e50;
            font-size: 12px;
            padding: 5px;
        }
        
        QProgressBar {
            border: 1px solid #bdc3c7;
            border-radius: 4px;
            text-align: center;
        }
        
        QProgressBar::chunk {
            background-color: #3498db;
            border-radius: 3px;
        }
    )");
    
    // 设置按钮对象名用于样式
    m_deleteButton->setObjectName("deleteButton");
}

void AdminMenuWidget::loadMenuData()
{
    if (!m_menuManager) return;
    
    m_allMenuItems = m_menuManager->getAllMenuItems();
    m_categories = m_menuManager->getAllCategories();
    
    showStatusMessage(QString("已加载 %1 个菜品").arg(m_allMenuItems.size()));
}

void AdminMenuWidget::updateMenuTable()
{
    m_menuTable->setSortingEnabled(false);
    m_menuTable->setRowCount(m_filteredMenuItems.size());
    
    for (int row = 0; row < m_filteredMenuItems.size(); ++row) {
        const MenuItem &item = m_filteredMenuItems.at(row);
        
        // ID (隐藏列)
        m_menuTable->setItem(row, COL_ID, new QTableWidgetItem(item.id));
        
        // 菜品名称
        m_menuTable->setItem(row, COL_NAME, new QTableWidgetItem(item.name));
        
        // 分类
        m_menuTable->setItem(row, COL_CATEGORY, new QTableWidgetItem(item.category));
        
        // 价格
        QTableWidgetItem *priceItem = new QTableWidgetItem();
        priceItem->setData(Qt::DisplayRole, item.price);
        priceItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
        m_menuTable->setItem(row, COL_PRICE, priceItem);
        
        // 库存
        QTableWidgetItem *stockItem = new QTableWidgetItem();
        stockItem->setData(Qt::DisplayRole, item.stock);
        stockItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
        // 库存不足时标红
        if (item.stock <= 5) {
            stockItem->setBackground(QColor("#ffebee"));
            stockItem->setForeground(QColor("#d32f2f"));
        }
        m_menuTable->setItem(row, COL_STOCK, stockItem);
        
        // 销量
        QTableWidgetItem *salesItem = new QTableWidgetItem();
        salesItem->setData(Qt::DisplayRole, item.salesCount);
        salesItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
        m_menuTable->setItem(row, COL_SALES, salesItem);
        
    }
    
    m_menuTable->setSortingEnabled(true);
    
    // 更新状态
    showStatusMessage(QString("显示 %1 个菜品").arg(m_filteredMenuItems.size()));
}

void AdminMenuWidget::updateCategoryFilter()
{
    QString currentCategory = m_categoryFilter->currentText();
    m_categoryFilter->clear();
    m_categoryFilter->addItem("全部分类");
    
    for (const QString &category : m_categories) {
        m_categoryFilter->addItem(category);
    }
    
    // 恢复选择
    int index = m_categoryFilter->findText(currentCategory);
    if (index >= 0) {
        m_categoryFilter->setCurrentIndex(index);
    }
}

void AdminMenuWidget::filterMenuData()
{
    QString searchText = m_searchEdit->text().trimmed();
    QString categoryFilter = m_categoryFilter->currentText();
    
    m_filteredMenuItems.clear();
    
    for (const MenuItem &item : m_allMenuItems) {
        bool matches = true;
        
        // 名称和ID搜索
        if (!searchText.isEmpty()) {
            bool nameMatches = item.name.contains(searchText, Qt::CaseInsensitive);
            bool idMatches = item.id.contains(searchText, Qt::CaseInsensitive);
            if (!nameMatches && !idMatches) {
                matches = false;
            }
        }
        
        // 分类过滤
        if (categoryFilter != "全部分类") {
            if (item.category != categoryFilter) {
                matches = false;
            }
        }
        
        if (matches) {
            m_filteredMenuItems.append(item);
        }
    }
    
    updateMenuTable();
}


void AdminMenuWidget::showMenuItemDetailsDialog(const MenuItem &item)
{
    if (!item.isValid()) {
        showStatusMessage("菜品信息无效", true);
        return;
    }
    
    // 创建详情对话框
    QDialog dialog(this);
    dialog.setWindowTitle(QString("菜品详情 - %1").arg(item.name));
    dialog.setModal(true);
    dialog.resize(450, 400);
    dialog.setMinimumSize(400, 350);
    
    // 主布局
    QVBoxLayout *mainLayout = new QVBoxLayout(&dialog);
    mainLayout->setContentsMargins(15, 15, 15, 15);
    mainLayout->setSpacing(10);
    
    // 标题
    QLabel *titleLabel = new QLabel(item.name, &dialog);
    titleLabel->setStyleSheet(
        "QLabel { "
        "font-size: 18px; "
        "font-weight: bold; "
        "color: #2c3e50; "
        "padding: 10px; "
        "background-color: #ecf0f1; "
        "border-radius: 5px; "
        "margin-bottom: 10px; "
        "}"
    );
    titleLabel->setAlignment(Qt::AlignCenter);
    mainLayout->addWidget(titleLabel);
    
    // 创建滚动区域
    QScrollArea *scrollArea = new QScrollArea(&dialog);
    scrollArea->setWidgetResizable(true);
    scrollArea->setStyleSheet(
        "QScrollArea { border: 1px solid #bdc3c7; border-radius: 3px; }"
    );
    
    QWidget *contentWidget = new QWidget();
    QFormLayout *formLayout = new QFormLayout(contentWidget);
    formLayout->setLabelAlignment(Qt::AlignRight);
    formLayout->setSpacing(8);
    
    // 菜品信息
    QLabel *idLabel = new QLabel(item.id);
    idLabel->setStyleSheet("color: #7f8c8d; font-family: monospace;");
    formLayout->addRow("菜品ID:", idLabel);
    
    QLabel *categoryLabel = new QLabel(item.category);
    categoryLabel->setStyleSheet("color: #3498db; font-weight: bold;");
    formLayout->addRow("分类:", categoryLabel);
    
    QLabel *priceLabel = new QLabel(QString("¥%1").arg(item.price, 0, 'f', 2));
    priceLabel->setStyleSheet("color: #e74c3c; font-weight: bold; font-size: 14px;");
    formLayout->addRow("价格:", priceLabel);
    
    QLabel *stockLabel = new QLabel(QString("%1 份").arg(item.stock));
    if (item.stock <= 5) {
        stockLabel->setStyleSheet("color: #e74c3c; font-weight: bold;");
    } else {
        stockLabel->setStyleSheet("color: #27ae60; font-weight: bold;");
    }
    formLayout->addRow("库存:", stockLabel);
    
    QLabel *salesLabel = new QLabel(QString("%1 份").arg(item.salesCount));
    salesLabel->setStyleSheet("color: #f39c12; font-weight: bold;");
    formLayout->addRow("销量:", salesLabel);
    
    // 描述
    if (!item.description.isEmpty()) {
        QTextEdit *descEdit = new QTextEdit();
        descEdit->setPlainText(item.description);
        descEdit->setReadOnly(true);
        descEdit->setMaximumHeight(80);
        descEdit->setStyleSheet(
            "QTextEdit { "
            "background-color: #f8f9fa; "
            "border: 1px solid #dee2e6; "
            "border-radius: 3px; "
            "padding: 5px; "
            "color: #495057; "
            "}"
        );
        formLayout->addRow("描述:", descEdit);
    } else {
        QLabel *noDescLabel = new QLabel("无描述");
        noDescLabel->setStyleSheet("color: #6c757d; font-style: italic;");
        formLayout->addRow("描述:", noDescLabel);
    }
    
    // 图片显示
    if (!item.imageUrl.isEmpty()) {
        QLabel *imageLabel = new QLabel();
        QPixmap pixmap(item.imageUrl);
        if (!pixmap.isNull()) {
            QPixmap scaledPixmap = pixmap.scaled(200, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation);
            imageLabel->setPixmap(scaledPixmap);
            imageLabel->setAlignment(Qt::AlignCenter);
            imageLabel->setStyleSheet(
                "QLabel { "
                "border: 2px solid #27ae60; "
                "border-radius: 5px; "
                "background-color: #ffffff; "
                "padding: 5px; "
                "}"
            );
        } else {
            imageLabel->setText("图片加载失败");
            imageLabel->setAlignment(Qt::AlignCenter);
            imageLabel->setStyleSheet(
                "QLabel { "
                "border: 2px dashed #e74c3c; "
                "border-radius: 5px; "
                "background-color: #f8f9fa; "
                "color: #e74c3c; "
                "padding: 20px; "
                "}"
            );
        }
        formLayout->addRow("菜品图片:", imageLabel);
        
        // 图片路径
        QString relativePath = item.imageUrl;
        QString projectRoot = QDir::currentPath();
        if (item.imageUrl.startsWith(projectRoot)) {
            relativePath = item.imageUrl.mid(projectRoot.length() + 1);
        }
        QLabel *pathLabel = new QLabel(relativePath);
        pathLabel->setStyleSheet("color: #6c757d; font-size: 10px; font-family: monospace;");
        pathLabel->setWordWrap(true);
        formLayout->addRow("图片路径:", pathLabel);
    } else {
        QLabel *noImageLabel = new QLabel("无图片");
        noImageLabel->setStyleSheet("color: #6c757d; font-style: italic;");
        formLayout->addRow("菜品图片:", noImageLabel);
    }
    
    // 时间信息
    QLabel *createdLabel = new QLabel(item.createdDate.toString("yyyy-MM-dd hh:mm:ss"));
    createdLabel->setStyleSheet("color: #6c757d; font-size: 11px;");
    formLayout->addRow("创建时间:", createdLabel);
    
    QLabel *modifiedLabel = new QLabel(item.lastModified.toString("yyyy-MM-dd hh:mm:ss"));
    modifiedLabel->setStyleSheet("color: #6c757d; font-size: 11px;");
    formLayout->addRow("修改时间:", modifiedLabel);
    
    scrollArea->setWidget(contentWidget);
    mainLayout->addWidget(scrollArea);
    
    // 按钮区域
    QHBoxLayout *buttonLayout = new QHBoxLayout();
    QPushButton *editBtn = new QPushButton("编辑菜品", &dialog);
    QPushButton *closeBtn = new QPushButton("关闭", &dialog);
    
    editBtn->setStyleSheet(
        "QPushButton { "
        "background-color: #3498db; "
        "color: white; "
        "border: none; "
        "padding: 8px 16px; "
        "border-radius: 4px; "
        "font-weight: bold; "
        "min-width: 80px; "
        "}"
        "QPushButton:hover { background-color: #2980b9; }"
    );
    
    closeBtn->setStyleSheet(
        "QPushButton { "
        "background-color: #95a5a6; "
        "color: white; "
        "border: none; "
        "padding: 8px 16px; "
        "border-radius: 4px; "
        "font-weight: bold; "
        "min-width: 80px; "
        "}"
        "QPushButton:hover { background-color: #7f8c8d; }"
    );
    
    buttonLayout->addWidget(editBtn);
    buttonLayout->addStretch();
    buttonLayout->addWidget(closeBtn);
    mainLayout->addLayout(buttonLayout);
    
    // 连接信号
    connect(editBtn, &QPushButton::clicked, [&]() {
        dialog.accept();
        // 触发编辑操作
        onEditMenuItemClicked();
    });
    
    connect(closeBtn, &QPushButton::clicked, &dialog, &QDialog::accept);
    
    // 设置对话框样式
    dialog.setStyleSheet(
        "QDialog { "
        "background-color: #ffffff; "
        "}"
        "QLabel { "
        "color: #2c3e50; "
        "}"
        "QFormLayout QLabel { "
        "font-weight: bold; "
        "min-width: 80px; "
        "}"
    );
    
    dialog.exec();
}

QString AdminMenuWidget::getMessageBoxStyleSheet() const
{
    return R"(
        QMessageBox {
            background-color: #f5f5f5;
            border: 2px solid #bdc3c7;
            border-radius: 8px;
            font-family: "DejaVu Sans", "SimSun", "Microsoft YaHei";
            font-size: 12px;
        }
        
        QMessageBox QLabel {
            color: #2c3e50;
            font-size: 13px;
            margin: 10px;
            background-color: transparent;
        }
        
        QMessageBox QPushButton {
            background-color: #3498db;
            color: #ffffff;
            border: none;
            border-radius: 4px;
            padding: 8px 20px;
            min-width: 80px;
            font-weight: bold;
            font-size: 12px;
        }
        
        QMessageBox QPushButton:hover {
            background-color: #2980b9;
        }
        
        QMessageBox QPushButton:pressed {
            background-color: #21618c;
        }
        
        QMessageBox QPushButton:focus {
            outline: none;
            border: 2px solid #5dade2;
        }
    )";
}


